package top.luo.mycat.server;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author luo
 * @date 2021-03-19 11:11
 */
public class Request {

    private String method;

    private String url;

    private InputStream ins;

    public Request() {
    }

    public Request(InputStream ins) throws IOException {
        this.ins = ins;
        // 读取输入流
        int available = ins.available();
        byte[] bytes = new byte[available];
        int read = ins.read(bytes);
        String inStr = new String(bytes);
        // 转换为相关属性
        // 第一行 请求行 请求方式
        String firstLine = inStr.split("\\n")[0];
        String[] firArr = firstLine.split(" ");
        this.method = firArr[0];
        this.url = firArr[1];

        System.out.println(method + " " + url);
    }

    public String getMethod() {
        return method;
    }

    public String getUrl() {
        return url;
    }

}
